<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String basePath = request.getContextPath();
    System.out.println("basePath = " + basePath);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script src="<%=basePath%>/js/jquery-1.7.2.js"></script>
    <script src="<%=basePath%>/js/ajaxfileupload.js"></script>
    <script type="text/javascript">

        function fileUpload() {
            var fileName = $("#upLoadFile").val();
            var sIndex = fileName.lastIndexOf(".") + 1;
            var eIndex = fileName.length;
            var extension = new String(fileName.substring(sIndex, eIndex));
            if (extension == "xls" || extension == "xlsx") {

            } else {
                alert("格式不正确，重新上传");
                return;
            }

            $.ajaxFileUpload({
                url: '<%=basePath %>/batchAgentPay',//用于文件上传的服务器端请求地址
                secureuri: false, //一般设置为false
                fileElementId: 'upLoadFile', //文件上传空间的id属性  <input type="file" id="file" name="file" />
                dataType: 'text', //返回值类型 一般设置为json
                success: function (data) {
                    alert(data);
                }
            })
        }
    </script>
</head>
<body>
<br>
<input type="file" id="upLoadFile" name="upLoadFile" onchange="fileUpload();">
<br>
<br>
</body>
</html>